namespace Brjnk.Common
{
    using System;
    using System.Windows.Input;

    /// <summary>
    /// </summary>
    public class GenericCommand : ICommand
    {
        public GenericCommand(Action<object> action)
        {
            this.Action = action;
        }

        public bool isAvailable = true;

        public bool IsAvailable
        {
            get { return isAvailable; }
            set
            {
                isAvailable = value;
                if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty);
            }
        }

        public Action<object> Action { get; set; }

        public bool CanExecute(object parameter)
        {
            return isAvailable;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            Action(parameter);
        }
    }
}